import { IParam, IContext, DataServiceBase, IHttpResponse } from '@/core';
import { ThirdDTOHelp,  } from '../dto-help/third-helps';
import { Third } from '../third';
import ThirdKeys from '../third-keys';


/**
 * Third服务对象基类
 * 基于template/src/api/{{appEntities}}/data-service/{{appEntities}}-service-base.ts.hbs生成
 *
 * @export
 * @class Third
 * @extends {EntityBaseService}
 */
export class ThirdServiceBase extends DataServiceBase<Third> {

	/**
	 * 存储模式
	 *
	 * @type {(0 | 1 | 3 | 4)} 无本地存储 | 仅本地存储 | 本地及远程存储 | DTO无存储
	 * @memberof ThirdServiceBase
   */
	readonly storageMode: number = 0;

	/**
	 * Creates an instance of ThirdServiceBase.
	 *
	 * @param {*} [opts={}]
	 * @memberof ThirdServiceBase
	 */
	constructor(opts: IParam = {}) {
		super(opts, 'Third');
	}

	/**
	 * 初始化基础数据
	 *
	 * @protected
	 * @memberof ThirdServiceBase
	 */
  protected initBasicData() {
		this.systemName = 'demosys';
		this.appName = 'web';
		this.appEntityName = 'third';
		this.appEntityCodeName = 'third';
		this.appEntityCodeNames = 'thirds';
    	this.appEntityKeyCodeName = 'thirdid';
      	this.appEntityTextCodeName = 'thirdname';
  	}

	/**
	 * 构造实体
	 *
	 * @protected
	 * @param {IParam} data
	 * @param {IContext} [context]
	 * @return {*} { Third }
	 * @memberof ThirdServiceBase
	 */
	protected newEntity(data: IParam, context: IContext = {}): Third {
    return new Third(data);
  }

	/**
	 * 过滤当前实体服务，标准接口数据
	 *
	 * @return {*}  {*}
	 * @memberof ThirdServiceBase
	 */
	protected filterEntityData(entity: Third): any {
		const data: any = {};
		ThirdKeys.forEach(key => {
				if (entity[key] !== void 0) {
						data[key] = entity[key];
				}
		});
		return data;
	}
















  	/**
  	 * Select
  	 *
  	 * @param {IParam} [context={}]
  	 * @param {IParam | IParam[]} [data]
  	 * @returns {Promise<any>}
  	 * @memberof ThirdServiceBase
  	 */
  	public async Select(context: IContext = {}, data: IParam | IParam[]): Promise<any> {
  		data = data ? data : {};
  		let requestPath = '';
  	  	requestPath = `/thirds/select`;
  	  	const res = await this.http.get(requestPath);
  	  	return res;
  	}

}